﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DSARepository.Utils;

namespace DSARepository
{
    public class ManagerRepo
    {
        public bool InsertSalesmanRecommend(string salesmanId, string OpenId)
        {
            bool result = false;
            //判断关注记录是否已经存在
            if (DbUtils.Main.Sql(@"select count(*) from salesmanrecommend where OpenId=@0", OpenId).QuerySingle<int>() == 0)
                result = DbUtils.Main.Insert("salesmanrecommend")
                             .Column("SalesmanId", salesmanId)
                             .Column("OpenId", OpenId)
                             .Column("CreateTime", DateTime.Now)
                             .Execute() > 0;
            return result;
        }

        public bool InsertUnSubccribeLog(string OpenId)
        {
            return DbUtils.Main.Insert("unsubscribelog")
                                .Column("OpenId", OpenId)
                                .Column("CreateTime", DateTime.Now)
                                .Execute() > 0;
        }
    }
}